var e = require("../../../@babel/runtime/helpers/interopRequireDefault")(require("../adService")), t = getApp(), o = null;

try {
    o = requirePlugin("adbright-ad").pageprocessing;
} catch (e) {
    console.log(e);
}

try {
    var n = o(t.adConfig, e.default);
    Page(n({
        data: {
            integral: "",
            placementId: "",
            mini_form_id: "",
            level_credit: 0,
            level_data: [],
            adv_list: [],
            member: {},
            level_index: 0,
            redirectToUrl: "",
            Partner: !1,
            pid: ""
        },
        onLoad: function(e) {
            var t = wx.getStorageSync("integral");
            t && this.setData({
                integral: t
            }), e.pid && (this.data.pid = e.pid), e.Partner ? (this.data.Partner = !0, this.data.redirectToUrl = "/packageF/sharedPartner/sharedPartner") : this.data.redirectToUrl = "/packageI/AdBright/AdBrightIndex/AdBrightIndex", 
            e.adv_id && e.wxad && (this.setData({
                placementId: e.adv_id,
                mini_form_id: e.wxad
            }), console.log("ssssssssssssssssssssssssssss", this.data.placementId, this.data.mini_form_id), 
            wx.showToast({
                duration: 2e3,
                title: "跳转广告中",
                icon: "none"
            }), this.getADData());
        },
        onShow: function() {},
        getADData: function(e) {
            this.setWeixinAdConfig({
                placementId: this.data.placementId,
                weixin: {
                    type: "motivation",
                    unitId: this.data.mini_form_id,
                    succcess: function() {
                        console.log("==============微信广告加载成功回调====================");
                    },
                    fail: function() {
                        console.log("==============微信广告加载失败回调====================");
                    }
                }
            }), t.adConfig.app_id && t.adConfig.domain ? this.getADDataVideo() : wx.showToast({
                icon: "none",
                title: "缺失广告配置信息",
                duration: 1e3
            });
        },
        getADDataVideo: function() {
            var e = this, t = this, o = this.getAdbrightData({
                placementId: this.data.placementId,
                success: function() {
                    console.log("getAdbrightData::请求success===========================");
                },
                fail: function() {
                    console.log("getAdbrightData::请求fail===========================");
                },
                weixin: {
                    type: "motivation",
                    unitId: this.data.mini_form_id,
                    adIntervals: 50,
                    adType: "video",
                    adTheme: "white",
                    success: function() {
                        console.log("==============微信广告加载成功回调222====================");
                    },
                    fail: function() {
                        console.log("==============微信广告加载失败回调222====================");
                    },
                    close: function() {}
                }
            });
            o.onClick = function() {
                console.log("自有广告被点击了");
            }, o.onError = function(e) {
                console.log("自有广告加载出错了或者加载失败了err: ", o, e), wx.showToast({
                    duration: 2e3,
                    title: "正在为您加载微信广告",
                    icon: "none"
                });
            }, o.onClose = function(t) {
                console.log("自有广告关闭了"), t.isEnded ? console.log("激励视频达到奖励条件") : console.log("激励视频未达到奖励条件"), 
                wx.redirectTo({
                    url: e.data.redirectToUrl
                });
            }, o.onEnd = function(e) {
                console.log("自有广告视频播放完毕"), t.data.Partner ? t.PartnerReward() : t.getReward();
            }, o.onWxEnd = function() {
                console.log("流量主广告播放完毕了===================");
            }, o.onWxShow = function() {
                console.log("流量主广告显示了");
            }, o.onWxError = function(e) {
                console.log("流量主广告加载出错了err: "), wx.showModal({
                    title: "提示",
                    content: "获取广告失败，请稍后重试",
                    showCancel: !1,
                    success: function(e) {
                        wx.redirectTo({
                            url: t.data.redirectToUrl
                        });
                    }
                });
            }, o.onWxClose = function(o) {
                if (console.log("流量主广告关闭了"), o.isEnded) {
                    if (t.data.Partner) return void t.PartnerReward(!0);
                    t.getReward(!0), console.log("流量主广告达到奖励条件");
                } else console.log("流量主广告未达到奖励条件"), wx.redirectTo({
                    url: e.data.redirectToUrl
                });
            };
        },
        PartnerReward: function(e) {
            var o = this, n = t.getNetAddresss("plugin.share-partner.frontend.dividend.draw");
            t._postNetWork({
                url: n,
                data: {
                    dividend_id: this.data.pid,
                    adv_id: this.data.placementId
                },
                success: function(t) {
                    var n = t.data;
                    wx.showModal({
                        title: "提示",
                        content: n.msg,
                        showCancel: !1,
                        success: function(t) {
                            e && wx.redirectTo({
                                url: o.data.redirectToUrl
                            });
                        }
                    });
                },
                fail: function(e) {
                    console.log(e);
                }
            });
        },
        getReward: function(e) {
            var o = this, n = t.getNetAddresss("plugin.flyers-advertise.frontend.reward.miniReward");
            t._postNetWork({
                url: n,
                data: {
                    adv_id: this.data.placementId
                },
                success: function(t) {
                    var n = t.data;
                    wx.showModal({
                        title: "提示",
                        content: n.msg,
                        showCancel: !1,
                        success: function(t) {
                            e && wx.redirectTo({
                                url: o.data.redirectToUrl
                            });
                        }
                    });
                },
                fail: function(e) {
                    console.log(e);
                }
            });
        },
        onReady: function() {},
        onHide: function() {},
        onUnload: function() {},
        onPullDownRefresh: function() {},
        onReachBottom: function() {},
        onShareAppMessage: function() {}
    }));
} catch (e) {}